<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="curPage"
    :page-sizes="pageSizes"
    :page-size="pageSize"
    :layout="layout"
    :total="pageTotal"
  ></el-pagination>
</template>
<script>
export default {
  name: "page",
  props: {
    curPage: {
      //当前页数
      type: Number,
      default: 1
    },
    pageSize: {
      //每页显示条目个数
      type: Number,
      default: 10
    },
    pageTotal: {
      //总条目数
      type: Number,
      default: 0
    },
    pageSizes: {
      //每页显示个数选择器的选项设置
      type: Array,
      default: () => [10, 20]
    },
    layout: {
      //组件布局
      type: String,
      default: "total, sizes, prev, pager, next, jumper"
    }
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
      this.refresh();
    },
    handleCurrentChange(val) {
      this.curPage = val;
      this.refresh();
    },
    setPageTotal(val) {
      this.pageTotal = val;
    }
  }
};
</script>
